﻿import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Controls.Styles 1.3
import QtQuick.Window 2.0
import QtQuick.Layouts 1.1
Item
{
     id:root

     property int rightM:Screen.width
     property int topM:Screen.height
     property bool mouseLeftClick:false
     property bool fullScreenState:false
     //
     property bool click1:true
     property bool click2:false
     property bool click3:false

     onMouseLeftClickChanged:
     {

         if(mouseLeftClick)
         {
             settingChildMenu.visible=false
             setting.source="./切图/头/设置.png"
         }
     }
     width:238
     height:width/238*30
    Image//退出按钮
    {
        id:exitApp
        width:parent.width/238*28
        height:width/28*29
        source:"./切图/头/退出.png"
        anchors.right:parent.right
        anchors.rightMargin: parent.height*0.5
        anchors.top:parent.top
        anchors.topMargin: 10
        opacity:0.85
        MouseArea
        {
            anchors.fill:exitApp
            hoverEnabled: true
            onEntered:
            {
                exitApp.opacity=1
            }
            onExited:
            {
                exitApp.opacity=0.85
            }
            onPressed: exitApp.source="./切图/头/退出点击.png"
            onReleased: exitApp.source="./切图/头/退出.png"
            onClicked:
            {
                //ssimCore.quit();
                mainApp.close();
                //TODO
            }

        }
    }
    /*
    Image//全屏按钮
    {
        id:fullScreen
        width:parent.width/238*28
        height:width/28*29
        source:"./切图/头/全屏.png"
        anchors.right:exitApp.left
        anchors.rightMargin:parent.height*0.5
        anchors.verticalCenter:exitApp.verticalCenter
        opacity:0.85

         MouseArea
         {
             anchors.fill:fullScreen
             hoverEnabled: true
             onEntered:
             {
                 fullScreen.opacity=1
             }
             onExited:
             {
                 fullScreen.opacity=0.85
             }
             onPressed: fullScreen.source="./切图/头/全屏点击.png"
             onReleased: fullScreen.source="./切图/头/全屏.png"
             onClicked:
             {
                 fullScreenState=!fullScreenState
                 th3dView.slotShowQML(false)
             }

         }
    }
    Image//设置按钮
    {
        id:setting
        width:parent.width/238*30
        height:width/30*29
        source:"./切图/头/设置.png"
        anchors.right:fullScreen.left
        anchors.rightMargin:15
        anchors.verticalCenter:exitApp.verticalCenter
        opacity:0.85
        MouseArea
        {
            anchors.fill:setting
            hoverEnabled: true
            onEntered:
            {
                setting.opacity=1
            }
            onExited:
            {
                setting.opacity=0.85
            }
            onPressed: setting.source="./切图/头/设置点击.png"
            onReleased: setting.source="./切图/头/设置.png"
            onClicked:
            {
                mouseLeftClick=false;
                settingChildMenu.visible=!settingChildMenu.visible //TODO
                setting.source=settingChildMenu.visible?"./切图/头/设置点击.png":"./切图/头/设置.png"
            }

        }
    }
    Image//用户按钮
    {
        id:userInfo
        width:parent.width/238*107
        height:width/107*31
        source:"./切图/头/用户.png"
        anchors.right:setting.left
        anchors.rightMargin:parent.height*0.5
        anchors.verticalCenter:exitApp.verticalCenter
        opacity:0.85
        MouseArea
        {
            anchors.fill:userInfo
            hoverEnabled: true
            onEntered:
            {
                userInfo.opacity=1
            }
            onExited:
            {
                userInfo.opacity=0.85
            }
            onPressed: userInfo.opacity=0.65
            onReleased: userInfo.opacity=0.85
            onClicked:
            {
//                login.visible=!login.visible//ToDo
            }

        }
    }*/
    //子选项
  property int leftMar:90
    Rectangle//设置
    {
        id:settingChildMenu
        width:settingChildMenuBg.width
        height:settingChildMenuBg.height
        anchors.top:root.top
        anchors.right:root.right
        anchors.rightMargin:rightM/2-settingChildMenuBg.width/2
        anchors.topMargin:topM/2-settingChildMenuBg.height/2
        color:"transparent"
        visible:false
        Image
        {
            id:settingChildMenuBg
            source:"./切图/设置/底子.png"
            MouseArea{anchors.fill:parent}
        }
        Image
        {
            id:closebutton
            source:"./切图/设置/关闭.png"
            anchors.top:settingChildMenuBg.top
            anchors.right:settingChildMenuBg.right
            anchors.topMargin:15
            anchors.rightMargin:15
            z:settingChildMenuBg.z+1
            MouseArea
            {
                anchors.fill:parent
                onPressed:closebutton.opacity=0.5
                onReleased:closebutton.opacity=1
                onClicked:
                {
                     settingChildMenu.visible=false
                     setting.source="./切图/头/设置.png"
                }
            }
        }
        Column
        {
            id:settingMenu
            width:132
            height:493
            anchors.top:parent.top
            anchors.left:parent.left
            anchors.topMargin:45
            Rectangle
            {
                id:item1
                color:"#444444"
                width:parent.width
                height:40
                border.width:0
                Text
                {
                    id:textthermdyOpacity
                    text:"透明度设置"
                    font.pixelSize:16
                    color:"white"
                    font.family: "黑体"
                    anchors.centerIn: parent

                }
                MouseArea
                {
                    anchors.fill:parent
                    onPressed:parent.color="#444444"
                    onReleased:parent.color="#1b1b1b"
                    onClicked:
                    {
                       selectMenuItem(1)

                    }
                }
            }

            Rectangle
            {
                id:item2
                color:"#1b1b1b"
                width:parent.width
                height:40
                Text
                {
                    id:textSateSetting
                    text:"运行卫星设置"
                    font.pixelSize:16
                    color:"white"
                    font.family: "黑体"
                    anchors.centerIn: parent
                }
                MouseArea
                {
                    anchors.fill:parent
                    onPressed:parent.color="#444444"
                    onReleased:parent.color="#1b1b1b"
                    onClicked:
                    {
                       selectMenuItem(2)


                    }
                }
            }

            Rectangle
            {
                id:item3
                color:"#1b1b1b"
                width:parent.width
                height:40
                Text
                {
                    id:textThreeDim
                    text:"立体设置"
                    font.pixelSize:16
                    color:"white"
                    font.family: "黑体"
                    anchors.centerIn: parent
                }
                MouseArea
                {
                    anchors.fill:parent
                    onPressed:parent.color="#444444"
                    onReleased:parent.color="#1b1b1b"
                    onClicked:
                    {
                       selectMenuItem(3)

                    }
                }
            }
        }
        Rectangle
        {
            width: parent.width-settingMenu.width
            height:493
            anchors.left:settingMenu.right
            anchors.top:parent.top
            anchors.topMargin:45
            color:"#444444"     //底图与菜单栏有色差 防止显示边界
            ScrollView //运行卫星设置
            {
            id:settingdata
            width: parent.width
            height:parent.height
            anchors.left:parent.left
            anchors.top:parent.top 
            horizontalScrollBarPolicy:Qt.ScrollBarAlwaysOff
            verticalScrollBarPolicy:Qt.ScrollBarAsNeeded

            ColumnLayout
            {
                id:data1
                width:parent.width
                height:parent.height
                anchors.left: parent.left
                anchors.top:parent.top
                Item
                {
                    id:layerOpacity
                    width:parent.width
                    height:40
                    Text
                    {   id:opacitySettingText
                        text:"图层透明度："
                        font.pixelSize:16
                        color:"white"
                        font.family: "黑体"
                        anchors.left:parent.left
                        anchors.leftMargin:20
                        anchors.verticalCenter: parent.verticalCenter

                    }
                }

                Item//热力图
                {
                    id:thermdy
                    width:parent.width
                    height:40
                    Text
                    {
                        id:text1
                        text:"热力图  "
                        color:"white"
                        anchors.left:parent.left
                        anchors.leftMargin:leftMar
                        anchors.verticalCenter: parent.verticalCenter
                        font.pixelSize: 14
                        font.family: "黑体"
                    }
                    SpinBoxSelf
                    {
                        id:opacity1
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.left:text1.right
                        anchors.leftMargin:40

                        onOpacityDataChanged:
                        {
                            //TODO
                             // 透明度为：0-100
                        }
                    }

                }
                Item//卫星云图
                {
                    id:sateCloud
                    width:parent.width
                    height:40
                    Text
                    {
                        id:text2
                        text:"卫星云图"
                        color:"white"
                        anchors.left:parent.left
                        anchors.leftMargin:leftMar
                        anchors.verticalCenter: parent.verticalCenter
                        font.pixelSize: 14
                        font.family: "黑体"
                    }
                    SpinBoxSelf
                    {
                        id:opacity2
                        width:leftMar
                        height:20
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.left: text2.right
                        anchors.leftMargin:40
                        onOpacityDataChanged:
                        {

                            //TODO
                            //  // 透明度为：0-100
                        }
                    }

                }
                 Item
                {
                    id:runningSateSetting
                    width:parent.width
                    height:40
                    Text
                    {
                        text:"运行卫星设置："
                        font.pixelSize:16
                        color:"white"
                        font.family: "黑体"
                        anchors.left:parent.left
                        anchors.leftMargin:20
                        anchors.verticalCenter: parent.verticalCenter

                    }
                }
                Item//显示轨迹
                {
                    id:showpath
                    width:parent.width
                    height:30
                    Text
                    {
                        text:"显示轨迹"
                        color:"white"
                        font.pixelSize: 14
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.left:parent.left
                        anchors.leftMargin: leftMar
                        font.family: "黑体"
                    }

                    Switch
                    {
                        checked: true
                        anchors.left: showpath.left
                        anchors.leftMargin:300
                        anchors.verticalCenter:parent.verticalCenter
                        style:switchStyle
                        onCheckedChanged:
                        {
                            //TODO
                            if(checked)
                            {}
                            else
                          {  }
                        }
                    }
                }
                Item//显示条带
                {
                    id:showBand
                    width:parent.width
                    height:30
                    Text
                    {
                        text:"显示条带"
                        color:"white"
                        font.pixelSize: 14
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.left:parent.left
                        anchors.leftMargin: leftMar
                         font.family: "黑体"
                    }
                    Switch
                    {
                        checked: false
                        anchors.left: showBand.left
                        anchors.leftMargin:300
                        anchors.verticalCenter:parent.verticalCenter
                        style:switchStyle
                        onCheckedChanged:
                        {
                            //TODO
                            if(checked)
                        {}
                            else
                           {}
                        }
                    }

                }
                Item//显示星下点
                {
                    id:showPoint
                    width:parent.width
                    height:30
                    Text
                    {
                        text:"显示星下点"
                        color:"white"
                        font.pixelSize: 14
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.left:parent.left
                        anchors.leftMargin: leftMar
                        font.family: "黑体"
                    }
                    Switch
                    {
                        checked: false
                        anchors.left: showPoint.left
                        anchors.leftMargin:300
                        anchors.verticalCenter:parent.verticalCenter
                        style:switchStyle
                        onCheckedChanged:
                        {
                            //TODO
                            if(checked)
                            {}
                            else
                            {}
                        }
                    }


                }
                Item//显示传感器
                {
                    id:showSenser
                    width:parent.width
                    height:30
                    Text
                    {
                        text:"显示传感器"
                        color:"white"
                        font.pixelSize: 14
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.left:parent.left
                        anchors.leftMargin: leftMar
                        font.family: "黑体"
                    }
                    Switch
                    {
                        checked: true
                        anchors.left: showSenser.left
                        anchors.leftMargin:300
                        anchors.verticalCenter:parent.verticalCenter
                        style:switchStyle
                        onCheckedChanged:
                        {
                            //TODO
                            if(checked)
                           {}
                            else
                           {}
                        }


                    }

                }
                Item
                {
                    id:thrDimSetting
                    width:parent.width
                    height:40
                    Text
                    {
                        text:"立体效果："
                        font.pixelSize:16
                        color:"white"
                        font.family: "黑体"
                        anchors.left:parent.left
                        anchors.leftMargin:20
                        anchors.verticalCenter: parent.verticalCenter

                    }
                }
                Item//3D
                {
                    id:show3D
                    width:parent.width
                    height:40
                    ExclusiveGroup
                    {
                        id:radioGroup3D
                        onCurrentChanged:
                        {
                            switch(current.text)
                            {
                            case "无":
                              {}
                                break
                            case "闪避立体":
                            {}
                                break

                            }
                            //TODO
                        }
                    }
                    RadioButton
                    {
                        id:nothreeDim
                        text:"无"
                        exclusiveGroup: radioGroup3D
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.left:parent.left
                        anchors.leftMargin:leftMar
                        style:radioStyle3D
                        checked:true

                    }
                    RadioButton
                    {
                        text:"闪避立体"
                        exclusiveGroup: radioGroup3D
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.left:nothreeDim.right
                        anchors.leftMargin:60
                        style:radioStyle3D

                    }

                }

            }
        }
        }
    }

  Component
    {
           id:switchStyle
            SwitchStyle
            {
                 groove:Rectangle
                {

                    implicitHeight:18
                    implicitWidth:50
                     color:control.checked?"#15d5b2":"#666666"
                     border.color: control.checked?"#15d5b2":"#666666"
                     border.width: 1
                }
                handle:Rectangle
               {
                   implicitHeight:18
                   implicitWidth:25
                   color:control.checked?"#ffffff":"#999999"
                   border.color: control.checked?"#15d9b2":"#4d4d4d"
                   border.width: 1
               }


            }
    }

    Component
    {
        id:radioStyle3D
            RadioButtonStyle
            {
            label:Text
            {
                color:"white"
                text:control.text
                font.pixelSize: 14
            }
            indicator:Rectangle
            {
                implicitHeight:16
                implicitWidth:16
                radius:8
                border.color:control.checked ? Qt.rgba(91/255,231/255,196/255,1) : "white"
                border.width: 1
                color:"transparent"
                Rectangle{
                    implicitHeight:8
                    implicitWidth:8
                    anchors.centerIn:parent
                    radius:4
                    visible:control.checked
                    color:Qt.rgba(91/255,231/255,196/255,1)
                }

            }
        }
    }
    function selectMenuItem(x)
    {
            click1=click2=click3=false
            item1.color=item2.color=item3.color="#1b1b1b"
            switch(x)
            {
            case 1:
                click1=true
                item1.color="#444444"
                settingdata.flickableItem.contentY=layerOpacity.y
                break
            case 2:
                click2=true
                item2.color="#444444"
                settingdata.flickableItem.contentY=runningSateSetting.y
                break
            case 3:
                click3=true
                item3.color="#444444"
                settingdata.flickableItem.contentY=thrDimSetting.y
                break
            }

        }




//                function setRunningState()
//                {
//                    if(showpath.checked)
//                    {
//                    }

//                    if(showBand.checked)
//                    {
//                    }
//                    if(showPoint.checked)
//                    {
//                    }
//                    if(showSenser.checked)
//                    {
//                    }
//                }
}


